package com.ds.generator;

import com.ds.model.MainTemplateConfig;
import freemarker.template.TemplateException;

import java.io.File;
import java.io.IOException;

public class MainGenerator {

    public static void main(String[] args) throws TemplateException, IOException {

        MainTemplateConfig mainTemplateConfig = new MainTemplateConfig();
        mainTemplateConfig.setAuthor("ds");
        mainTemplateConfig.setLoop(true);
        mainTemplateConfig.setOutputText("输出结果：");
        doGenerate(mainTemplateConfig);

    }
    public static void doGenerate(Object model) throws TemplateException, IOException {

        String inputRootPath = "D:\\星球项目\\ds-generator\\ds-generator-demo-projects\\acm-template-pro";
        String outputRootPath = "D:\\星球项目\\ds-generator";

        String inputPath;
        String outputPath;

        inputPath = new File(inputRootPath,"src/com/ds/acm/MainTemplate.java.ftl").getAbsolutePath();
        outputPath = new File(outputRootPath,"src/com/ds/acm/MainTemplate.java").getAbsolutePath();
        DynamicGenerator.doGenerate(inputPath, outputPath, model);

        inputPath = new File(inputRootPath,".gitignore").getAbsolutePath();
        outputPath = new File(outputRootPath,".gitignore").getAbsolutePath();
        StaticGenerator.copyFilesByHutool(inputPath,outputPath);

        inputPath = new File(inputRootPath,"README.md").getAbsolutePath();
        outputPath = new File(outputRootPath,"README.md").getAbsolutePath();
        StaticGenerator.copyFilesByHutool(inputPath,outputPath);

    }
}
